This repository has no description
1.7 kB
67 lines
1import { ApiClient } from '@/api-client';
2import { createClientTokenManager } from '@/services/auth';
3import OpenGraphCard from '@/features/openGraph/components/openGraphCard/OpenGraphCard';
4import { truncateText } from '@/lib/utils/text';
5
6interface Props {
7 params: Promise<{ handle: string }>;
8}
9
10export const contentType = 'image/png';
11export const size = {
12 width: 1200,
13 height: 630,
14};
15
16export default async function Image(props: Props) {
17 const { handle } = await props.params;
18
19 const apiClient = new ApiClient(
20 process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3000',
21 createClientTokenManager(),
22 );
23
24 const profile = await apiClient.getProfile({ identifier: handle });
25
26 return await OpenGraphCard({
27 children: (
28 <div style={{ display: 'flex', flexDirection: 'column' }}>
29 {profile.avatarUrl && (
30 <img
31 src={profile.avatarUrl}
32 width={164}
33 height={164}
34 alt={`${handle}'s avatar`}
35 style={{ borderRadius: '20px', marginTop: 'auto' }}
36 />
37 )}
38 <div
39 style={{
40 display: 'flex',
41 flexDirection: 'column',
42 gap: 10,
43 marginTop: '35px',
44 }}
45 >
46 <p
47 style={{
48 fontSize: '64px',
49 lineHeight: '20px',
50 }}
51 >
52 {truncateText(profile.name, 20)}
53 </p>
54 <p
55 style={{
56 fontSize: '40px',
57 lineHeight: '20px',
58 color: '#23AFED',
59 }}
60 >
61 @{truncateText(truncateText(profile.handle), 35)}
62 </p>
63 </div>
64 </div>
65 ),
66 });
67}